/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.ucase.casemain.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.common.core.page.PageResponse;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CasePartiesPersonInfoDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CasePartiesPersonInfoPageRequest;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CasePartiesPersonInfoQueryDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.service.ICasePartiesPersonInfoService;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CasePartiesPersonInfoVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述: 案件当事人个人详细信息-TRJ case_parties_person_info 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年02月15日
 */
@RestController
@RefreshScope
@RequestMapping("/punish/ucase/caseParties/person")
@Slf4j
public class CasePartiesPersonInfoController extends BaseController {
    @Resource
    private ICasePartiesPersonInfoService casePartiesPersonInfoService;


    /**
     * 【V1.0.0】描述：保存案件当事人-个人信息
     *
     * @param saveDto {@link CasePartiesPersonInfoDto}
     * @return {@link Result <String>} 保存结果
     * @author xiangyuyu
     * @date 2022-02-18 16:02
     */
    @PostMapping("/saveCasePartiesPersonInfo")
    @ApiOperation(value = "【V1.0.0】描述：保存案件当事人-个人信息", httpMethod = "POST")
    public Result<String> saveCasePartiesPersonInfo(@RequestBody @Validated CasePartiesPersonInfoDto saveDto) {
        int count = casePartiesPersonInfoService.saveCasePartiesPersonInfo(saveDto);
        return (count == Constant.INTEGER_1) ?
                Result.success(Constant.STRING_SAVE_SUCCESS) : Result.error(Constant.STRING_SAVE_FAIL);
    }

    /**
     * 【V1.0.0】描述：获取案件当事人-个人信息分页列表
     *
     * @param pageRequest {@link CasePartiesPersonInfoPageRequest}
     * @return {@link Result<   PageResponse   <CasePartiesPersonInfoVo>>} 案件当事人-个人信息分页列表
     * @author xiangyuyu
     * @date 2022-02-18 16:02
     */
    @PostMapping("/getCasePartiesPersonInfoPageList")
    @ApiOperation(value = "【V1.0.0】描述：获取案件当事人-个人信息分页列表", httpMethod = "POST")
    public Result<PageResponse<CasePartiesPersonInfoVo>> getCasePartiesPersonInfoPageList(@RequestBody @Validated CasePartiesPersonInfoPageRequest pageRequest) {
        List<CasePartiesPersonInfoVo> list = casePartiesPersonInfoService.getCasePartiesPersonInfoPageList(pageRequest);
        return Result.success(Constant.STRING_GET_SUCCESS, new PageResponse<>(list));
    }

    /**
     * 【V1.0.0】描述：获取案件当事人-个人信息列表
     *
     * @param queryDto {@link CasePartiesPersonInfoQueryDto}
     * @return {@link Result<List<CasePartiesPersonInfoVo>>} 案件当事人-个人信息列表
     * @author xiangyuyu
     * @date 2022-02-18 16:02
     */
    @PostMapping("/getCasePartiesPersonInfoList")
    @ApiOperation(value = "【V1.0.0】描述：获取案件当事人-个人信息列表", httpMethod = "POST")
    public Result<List<CasePartiesPersonInfoVo>> getCasePartiesPersonInfoList(@RequestBody @Validated CasePartiesPersonInfoQueryDto queryDto) {
        List<CasePartiesPersonInfoVo> list = casePartiesPersonInfoService.getCasePartiesPersonInfoList(queryDto);
        return Result.success(Constant.STRING_GET_SUCCESS, list);
    }

    /**
     * 【V1.0.0】描述：根据唯一标识查询案件当事人-个人信息
     *
     * @param id 唯一标识
     * @return {@link Result<CasePartiesPersonInfoVo>} 案件当事人-个人信息
     * @author xiangyuyu
     * @date 2022-02-18 16:02
     */
    @PostMapping("/getCasePartiesPersonInfo")
    @ApiOperation(value = "【V1.0.0】描述：根据唯一标识查询案件当事人-个人信息", httpMethod = "POST")
    public Result<CasePartiesPersonInfoVo> getCasePartiesPersonInfo(@RequestParam String id) {
        CasePartiesPersonInfoVo vo = casePartiesPersonInfoService.getCasePartiesPersonInfo(id);
        return Result.success(Constant.STRING_GET_SUCCESS, vo);
    }

    /**
     * 【V1.0.0】描述：删除案件当事人-个人信息
     *
     * @param id 主键id
     * @return {@link Result<String>} 删除结果
     * @author xiangyuyu
     * @date 2022-02-18 16:02
     */
    @PostMapping("/removeCasePartiesPersonInfo")
    @ApiOperation(value = "【V1.0.0】描述：删除案件当事人-个人信息", httpMethod = "POST")
    public Result<String> removeCasePartiesPersonInfo(@RequestParam String id) {
        return casePartiesPersonInfoService.removeCasePartiesPersonInfo(id);
    }
}